package com.framework.core.mvp;

import android.os.Bundle;
import android.view.View;

import com.framework.core.TitleBaseActivity;

/**
 * @author shenmengchao
 * @version 1.0.0
 * @date 2017/7/18
 * @description
 */

public abstract class TitlePresenterActivity<P extends BasePresenter> extends TitleBaseActivity implements BaseView{

    public P mPresenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void initActivity(View view){
        this.mPresenter = getPresenter();
        if (null != mPresenter) {
            mPresenter.attachView(this);
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (null != mPresenter) {
            mPresenter.detachView();
        }
    }

    public abstract P getPresenter();

    @Override
    public void onShowLoadingDialog() {
        showLoadingDialog();
    }

    @Override
    public void onDismissLoadingDialog() {
        dismissLoadingDialog();
    }

    @Override
    public void onSetRefreshComplete() {
        if (useSwipeRefreshLayout()) {
            mSwipeRefresh.setRefreshing(false);
        }
    }
}
